package main

import "math"

func reverse(x int) int {
	rel := 0
	for x != 0 {
		if rel > math.MaxInt32/10 || rel < math.MinInt32/10 {
			return 0
		}
		temp := x % 10
		x /= 10
		rel = rel*10 + temp
	}
	return rel
}
